<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
  
<div id="app">
<ras ref="ras"></ras>
<p>
    <button @click="$refs.ras.setFocus()">点击我</button>
</p>

</div>
  
<script>
const app = Vue.createApp({});
app.component('ras', {
    template: `<p><input ref="JJ"></p>`,
    methods:{
        setFocus(){
            this.$refs.JJ.focus();
        }
    }
})


app.mount('#app');


</script>
</body>
</html>